<?php
	session_start();
	include "../db.php";
	$current_user_id = $_SESSION['user_id'];
	$current_user_username = $_SESSION['username'];
	if(!isset($_SESSION['username'])) {
		session_destroy();
		header("location:../login/login.php?msg=line_13123");
	}
	if(!isset($_GET['username'])) $username = $_SESSION['username'];
	$username = $_GET['username'];
?>
<head>

<link rel="stylesheet" type="text/css" href="../css/css1.css">

<script type="text/javascript" src="../scripts/script1.js"></script>
<script type="text/javascript" src="../scripts/script2.js"></script>
<script type="text/javascript" src="../scripts/script3.js"></script>
<script type="text/javascript" src="../scripts/script4.js"></script>
<script type="text/javascript" src="../scripts/script5.js"></script>

</head>

<body onLoad=return set()>
<div class='divCell_input' style='width:15%;height:100%'>
	<div class='divCell_input' style='width:100%;height:15%'> 
		<img alt='Profile Picture'></img>
	</div>
	<div class='divCell_input' style='width:100%;height:84%' id='sdf'> 
		<?php 
			include "../left_bottom_navigation.php";
		?>
	</div>
</div>
<div class='divCell_input' style='width:84%;height:15%'>
	<? echo $_SESSION['username']; ?>
</div>
<div class='divCell_input' style='width:84%;height:100%'>
	<font color='blue'> <b><?php echo "All your team : ".$username; ?></b> </font>
	<div class='divTable' style='width:100%'>
	<?
		$all_user_team_query = "select * from team where leader_id = '$username'";
		$all_user_team_rs = mysql_query($all_user_team_query) or die("Error in query 44");
		
		$team_sr_no = 0;
		
		while(($all_user_team_row=mysql_fetch_assoc($all_user_team_rs))!=NULL)
		{
			$team_members = "<ul>";
			$team_sr_no = $team_sr_no + 1;
			/* team_id,team_name and description */
			$team_id = $all_user_team_row['id'];
			$team_name = $all_user_team_row['name'];
			$team_description = $all_user_team_row['description'];
			
			$all_team_member_query = "select member_id from team_member where team_id = '$team_id'";
			$all_team_member_rs = mysql_query($all_team_member_query) or die("Error in query 58");
			
			while(($all_team_member_row=mysql_fetch_assoc($all_team_member_rs))!=NULL)
			{
				$team_member = $all_team_member_row['member_id'];
				if(trim($team_member)!="") {
					$team_members = $team_members."<li>$team_member($team_id)</li>";
				}
			}
			$team_members = $team_members."</ul>";
			
			/* to find the no of projects the team has done */
			
			$all_team_of_project_query = "select * from team_problem where team_id = '$team_name'";
			$all_team_of_project_rs = mysql_query($all_team_of_project_query);
			$total_projects = mysql_num_rows($all_team_of_project_rs);
			?>
			<div class='divRow' style='width:100%'>
				<div class='divTable' style='width:100%'>
					<div class='divRow'>
						<div class='divCell_info' style='width:60%;border:none'>
							<? echo $team_sr_no.". ".$team_name; ?>
						</div>
						<div class='divCell_info' style='width:39%;border:none'>
							Total Projects : <label id='total_projects'><? echo $total_projects; ?></label>
						</div>
					</div>
					<div class='divRow' style='width:50%;border:none'>
						<div class='divCell_info' style='width:60%;border:none'>
							Description : <? echo $team_description; ?>
						</div>
						<div class='divCell_info' style='width:39%;border:none'>
							Team Members : <? echo $team_members; ?>
						</div>
					</div>
				</div>
			</div>
		<?
		}
		?>
	</div>
</body>